//
//  CheckBox.m
//  iDoctor
//
//  Created by Joshua Boverhof on 3/29/11.
//  Copyright 2011 LBNL. All rights reserved.
//

#import "CheckBox.h"


@implementation CheckBox
@synthesize isChecked;

- (id)initWithFrame:(CGRect)frame {
	if (self = [super initWithFrame:frame]) {
		// Initialization code
		
		self.contentHorizontalAlignment =
		UIControlContentHorizontalAlignmentLeft;
		
		[self setImage:[UIImage imageNamed:
						@"checkbox_not_ticked.png"]
			  forState:UIControlStateNormal];
		
		[self addTarget:self action:
		 @selector(checkBoxClicked)
	   forControlEvents:UIControlEventTouchUpInside];
	}
	return self;
}

-(IBAction) checkBoxClicked{
	if(self.isChecked ==NO){
		self.isChecked =YES;
		[self setImage:[UIImage imageNamed:
						@"checkbox_ticked.png"]
			  forState:UIControlStateNormal];
		
	}else{
		self.isChecked =NO;
		[self setImage:[UIImage imageNamed:
						@"checkbox_not_ticked.png"]
			  forState:UIControlStateNormal];
		
	}
}

- (void)dealloc {
	[super dealloc];
}

@end
